const express=require('express');
const router=express.Router();
const douban =require('../utils/movie')
router.get('/movieList',async (req,res)=>{
  var query=req.query
  var page_start=req.query.page_start
  var tag=''
  if(query&&page_start)
  tag=query.type
  else
  {tag='热门';page_start=0}

  var info = await douban.getMovieList(tag,Number(page_start)).catch(err=>console.log(err,'movieErr'))
  console.log(req.query)
  res.send(JSON.stringify(info) )
})
router.get('/tvList',async(req,res)=>{
  var query=req.query
  var page_start=req.query.page_start
  var tag=''
  if(query&&page_start)
  tag=query.type
  else
  {tag='热门';page_start=0}

  var info = await douban.getTvList(tag,page_start).catch(err=>console.log(err,'tvErr'))
  console.log(info)
  res.send(JSON.stringify(info) )
})

module.exports=router